<!--
@author	Yi Bo <etng2004@gmail.com>
@version	$Id: staff_list.php 38 2007-09-01 10:23:16Z etng2004 $
@copyrithg	2006-2007 ETE.CN
@license 	PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
-->
<?php
$this->declareVars();
require_once(dirname(__FILE__) . '/_meta_staff.php');
echo $this->render('header.php');
//$this->dump($this->staffs);

/**
 * 列表相应参数
 */
$checkbox_group = 'Staff';
?>
<script type="text/javascript">
<!--
function validateBatchOperateForm(checkboxGroup)
{
	var errors=[];
	if(!checkboxGroup.selected.length)errors.push('请选择至少一个对象！');

//	var f_status = document.getElementById('field_status');
//	var v_status = f_status.options[f_status.selectedIndex].value;
//	if(v_status=="")errors.push('请选择至少一种批量操作！');

	if(errors.length)
	{
		alert("请纠正以下错误后再继续操作：\n\n"+errors.join("\n"));
		return false;
	}
	return true;
}
//-->
</script>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
  <tr>
    <td><!--表头区域，可以用来做搜索等信息的展示-->
    </td>
  </tr>
  <tr>
    <td align="center" valign="top">
    <form method="post" action="<?php echo $this->base_url; ?>/batchOperate/" id="frmBatchOperate" name="frmBatchOperate" onsubmit="return validateBatchOperateForm(<?php echo $checkbox_group;?>ChkGroup);">
    <table id="<?php echo strtolower($checkbox_group);?>_list" cellspacing="0" cellpadding="0" class="tblborder">
        <tr class="tblhead">
          <td> - </td>
    	<td><?php echo $meta['staff']['fields']['id'];?></td>
	 	<td><?php echo $meta['staff']['fields']['username'];?></td>
	 	<td><?php echo $meta['staff']['fields']['name'];?></td>
	 	<td><?php echo $meta['staff']['fields']['email'];?></td>
	 	<td><?php echo $meta['staff']['fields']['qq'];?></td>
	 	<td><?php echo $meta['staff']['fields']['created_at'];?></td>
	 	<td><?php echo $meta['staff']['fields']['updated_at'];?></td>
          <td> 操作 </td>
        </tr>
        <?php
        if(!$this->staffs):
	?>
        <tr class="tblbody">
          <td colspan="20"> 无记录 </td>
        </tr>
        <?php
        else:
        foreach ($this->staffs as $staff):
	?>
        <tr class="tblbody">
          <td><input type="checkbox" name="fields[<?php echo strtolower($checkbox_group);?>_id][]" id="fields_<?php echo strtolower($checkbox_group);?>_<?php echo $staff['id']; ?>" value="<?php echo $staff['id']; ?>"/>
          </td>
     	<td><?php echo $staff['id'];?></td>
	 	<td><?php echo $staff['username'];?></td>
	 	<td><?php echo $staff['name'];?></td>
	 	<td><?php echo $staff['email'];?></td>
	 	<td><?php echo $staff['qq'];?></td>
	 	<td><?php echo date('Y-m-d', $staff['created_at']);?></td>
	 	<td><?php echo date('Y-m-d', $staff['updated_at']);?></td>
          <td>
          <a href=" <?php echo $this->base_url;?>/view/id/<?php echo $staff['id'] ?>">查看</a>
          <a href=" <?php echo $this->base_url;?>/edit/id/<?php echo $staff['id'] ?>">编辑</a>
          <a href=" <?php echo $this->base_url;?>/remove/id/<?php echo $staff['id'] ?>">删除</a>
            </td>
        </tr>
        <?php
        endforeach;
	?>
        <tr class="tblfoot">
          <td colspan="20">
		<a href="javascript:void(0);" onclick="<?php echo $checkbox_group;?>ChkGroup.all();">全选</a>
		<a href="javascript:void(0);" onclick="<?php echo $checkbox_group;?>ChkGroup.inverse();">反选</a>
		<a href="javascript:void(0);" onclick="<?php echo $checkbox_group;?>ChkGroup.clear();">不选</a>
		对选中的对象：
  <select name="operate[status]" id="field_status">
  <option value="">===审核===</option>
<?php
$lang_status_op = array();
foreach ($lang_status_op as $status => $text) {
	if($this->status==$status)continue;
	echo "<option value=\"{$status}\">{$text}</option>\n";
}
  ?>
  </select><input type="submit" value="设置"  />
          </td>
        </tr>
        <tr class="tblfoot">
          <td colspan="20"><?php
          echo $this->pagination($this->pager['total'], $this->pager['curpage'], $this->pager['perpage'], $this->pager['url'] );
?>
          </td>
        </tr>
        <?php
        endif;
	?>
      </table>
      </form>
      <script type="text/javascript">
      <!--
      var <?php echo $checkbox_group;?>ChkGroup = new EtCheckboxes('<?php echo strtolower($checkbox_group);?>_list','fields_<?php echo strtolower($checkbox_group);?>_',[]);
      //-->
</script>
      </td>
  </tr>
  <tr>
    <td>others</td>
  </tr>
</table>
<div class="develop_notice">
  <h3>Head</h3>
  <textarea name="CRMLiteDevelopCodeListHead" rows="10" cols="50" wrap="off" onfocus="this.select();">	<tr>
    <?php
        foreach ($staff as $field => $value):
	?>
	<td>&lt;?php echo $meta['staff']['fields']['<?php echo $field; ?>'];?&gt;</td>
	 <?php
        endforeach;
	?>
	</tr>
</textarea>
  <h3>Body</h3>
  <textarea name="CRMLiteDevelopCodeListBody" rows="10" cols="50" wrap="off" onfocus="this.select();">
     <?php
        foreach ($staff as $field => $value):
	?>
	<td>&lt;?php echo $staff['<?php echo $field; ?>'];?&gt;</td>
	 <?php
        endforeach;
	?>
	</tr>
</textarea>
</div>
<?php echo $this->render('footer.php');?>